﻿using UnityEngine;
using System.Collections;

public class DropShadowAnim : MonoBehaviour {

	public float radius = 0.15f;
	public float maxAngle = 45.0f;
	public float period = 2.0f;

	void Update()
	{
		float phase = Time.realtimeSinceStartup * (2.0f * Mathf.PI) / period;
		float angle = Mathf.Sin (phase) * (Mathf.Deg2Rad * maxAngle);

		float startX = 0.0f;
		float startY = -radius;
		float sinAngle = Mathf.Sin (angle);
		float cosAngle = Mathf.Cos (angle);
		float x = cosAngle * startX - sinAngle * startY;
		float y = sinAngle * startX + cosAngle * startY;

		transform.localPosition = new Vector3 (x, y, 0.0f);
	}
}
